From c2594ca7f36b40ebd5fb64744a329c2eb4a06f38 Mon Sep 17 00:00:00 2001 From: Boyuan Yang Date: Fri, 30 Aug 2019 11:18:48 -0400 Subject: [PATCH] New upstream version 1.0.5+git20190530 --- .travis.yml | 55 +++++++++++++++----- README.md | 12 +++-- appveyor.yml | 40 ++++++++++++++ binding.gyp | 2 +- data/dictionary/STPhrases.txt | 8 +-- node/dicts.gypi | 2 +- node/{node_binding.gypi => node_opencc.gypi} | 4 +- node/{binding.cc => opencc.cc} | 0 node/opencc.js | 5 +- package.json | 16 ++++-- src/BinaryDict.cpp | 2 +- src/DartsDict.cpp | 2 +- src/DictConverter.hpp | 2 +- src/Exception.hpp | 5 +- src/PhraseExtractTest.cpp | 2 + src/TextDict.cpp | 2 +- 16 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 appveyor.yml rename node/{node_binding.gypi => node_opencc.gypi} (76%) rename node/{binding.cc => opencc.cc} (100%) diff --git a/.travis.yml b/.travis.yml index 676a238..7f71b24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,42 @@ -language: cpp -compiler: - - gcc -sudo: required -before_install: - - sudo add-apt-repository -y ppa:chris-lea/node.js - - sudo apt-get update - - sudo apt-get install nodejs -y - - sudo apt-get install doxygen -y - - sudo npm install -g mocha - - sudo npm install -g node-gyp - - sudo npm install -script: make test VERBOSE=1 && make package VERBOSE=1 && make node-test +language: node_js + +cache: + npm: true + ccache: true + +node_js: + - stable + - 10 + - 8 + - 6 + +os: + - linux + - osx + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - doxygen + - g++-4.8 + +# Install scripts. (runs after repo cloning) +install: + - if [ $TRAVIS_OS_NAME == "linux" ]; then export CXX=g++-4.8; fi + # install modules + - npm install --build-from-source + +# Post-install test scripts. +script: + - export PATH="/usr/lib/ccache/:$PATH" + - if [ $TRAVIS_OS_NAME == "linux" ] && [ $TRAVIS_NODE_VERSION == "stable" ]; then + make test VERBOSE=1; + make package VERBOSE=1; + fi + + - npm test + +after_success: + - npm run deploy diff --git a/README.md b/README.md index 9930340..8551558 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Open Chinese Convert 開放中文轉換 [ ![Download](https://api.bintray.com/packages/byvoid/opencc/OpenCC/images/download.svg) ](https://bintray.com/byvoid/opencc/OpenCC/_latestVersion) -[![Build Status](https://travis-ci.org/BYVoid/OpenCC.svg?branch=master)](https://travis-ci.org/BYVoid/OpenCC) +[![Travis](https://img.shields.io/travis/BYVoid/OpenCC.svg)](https://travis-ci.org/BYVoid/OpenCC) +[![AppVeyor](https://img.shields.io/appveyor/ci/Carbo/OpenCC.svg)](https://ci.appveyor.com/project/Carbo/OpenCC) ## Introduction 介紹 @@ -99,19 +100,20 @@ cmake --build build --config Release --target install See https://github.com/gelosie/OpenCC/tree/master/iOS +Or [SwiftyOpenCC](https://github.com/XQS6LB3A/SwiftyOpenCC) + ### Android See [android-opencc](https://github.com/qichuan/android-opencc) ## Projects using Opencc 使用OpenCC的項目 -* [ibus-pinyin](http://code.google.com/p/ibus/) -* [fcitx](http://code.google.com/p/fcitx/) -* [rimeime](http://code.google.com/p/rimeime/) +* [ibus-pinyin](https://github.com/ibus/ibus-pinyin) +* [fcitx](https://github.com/fcitx/fcitx) +* [rimeime](https://rime.im/) * [libgooglepinyin](http://code.google.com/p/libgooglepinyin/) * [ibus-libpinyin](https://github.com/libpinyin/ibus-libpinyin) * [BYVBlog](https://github.com/byvoid/byvblog) -* [豆瓣同城微信](http://weixinqiao.com/douban-event/) * [alfred-chinese-converter](https://github.com/amowu/alfred-chinese-converter) * [GoldenDict](https://github.com/goldendict/goldendict) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..599ad6e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,40 @@ +version: "{build}" +skip_branch_with_pr: true +skip_tags: true +build: off + +environment: + matrix: + - nodejs_version: stable + - nodejs_version: 10 + - nodejs_version: 8 + - nodejs_version: 6 + +platform: + - x64 + - x86 + +# Install scripts. (runs after repo cloning) +install: + # install Node.js + - ps: Install-Product node $env:nodejs_version $env:platform + # Get the latest stable version of npm + - npm -g i npm@latest + # install modules + - appveyor-retry call npm install --build-from-source + +# to run your custom scripts instead of automatic tests +test_script: + - IF %nodejs_version%==stable cmake -H. -Bbuild -G"Visual Studio 12" + - IF %nodejs_version%==stable cmake --build build --config Release --target install + - npm test + +# pushing entire folder as a zip archive +artifacts: + - path: build/src/tools/Release + name: OpenCC + type: zip + +# to run your custom scripts instead of provider deployments +deploy_script: + - npm run deploy diff --git a/binding.gyp b/binding.gyp index 89ae598..ccc7a0f 100644 --- a/binding.gyp +++ b/binding.gyp @@ -3,6 +3,6 @@ "node/global.gypi", "node/configs.gypi", "node/dicts.gypi", - "node/node_binding.gypi", + "node/node_opencc.gypi", ] } diff --git a/data/dictionary/STPhrases.txt b/data/dictionary/STPhrases.txt index 28f14fd..141d137 100644 --- a/data/dictionary/STPhrases.txt +++ b/data/dictionary/STPhrases.txt @@ -9006,7 +9006,7 @@ 化学工厂 化學工廠 化学弹药 化學彈藥 化学当量 化學當量 -化学战斗部 化學戰斗部 +化学战斗部 化學戰鬥部 化学系 化學系 化学纤维 化學纖維 化工厂 化工廠 @@ -29386,7 +29386,7 @@ 杨胜旭 楊勝旭 杨致远 楊致遠 杨苏棣 楊甦棣 -杨采妮 楊採妮 +杨采妮 楊采妮 杨雅筑 楊雅筑 杪秋 杪秋 杭丁顿舞蹈症 杭丁頓舞蹈症 @@ -30259,7 +30259,7 @@ 核当量 核當量 核心 核心 核战 核戰 -核战斗部 核戰斗部 +核战斗部 核戰鬥部 核批 覈批 核技术 核技術 核报 覈報 @@ -46406,7 +46406,7 @@ 间深里 間深裏 闵凶 閔凶 闵子里 閔子裏 -闵采尔 閔採爾 +闵采尔 閔采爾 闷出 悶出 闷在心里 悶在心裏 闷板 悶板 diff --git a/node/dicts.gypi b/node/dicts.gypi index 3b96381..0ea3452 100644 --- a/node/dicts.gypi +++ b/node/dicts.gypi @@ -152,7 +152,7 @@ "action": ["node", "<(cmd)", "<(input)", "<@(_outputs)"] }], "dependencies": [ - "binding" + "opencc" ] }] } diff --git a/node/node_binding.gypi b/node/node_opencc.gypi similarity index 76% rename from node/node_binding.gypi rename to node/node_opencc.gypi index 6022195..2db8fdd 100644 --- a/node/node_binding.gypi +++ b/node/node_opencc.gypi @@ -1,8 +1,8 @@ { "targets": [{ - "target_name": "binding", + "target_name": "opencc", "sources": [ - "../node/binding.cc", + "../node/opencc.cc", ], "include_dirs": [ "../src", diff --git a/node/binding.cc b/node/opencc.cc similarity index 100% rename from node/binding.cc rename to node/opencc.cc diff --git a/node/opencc.js b/node/opencc.js index 70f9564..67be63f 100644 --- a/node/opencc.js +++ b/node/opencc.js @@ -27,9 +27,10 @@ */ var path = require('path'); -var binding = require('../build/Release/binding'); +var bindingPath = require('node-pre-gyp').find(require.resolve('../package.json')); +var binding = require(bindingPath); -var assetsPath = path.resolve(__dirname, '../build/Release'); +var assetsPath = path.dirname(bindingPath); var getConfigPath = function (config) { var configPath = config; if (config[0] !== '/' && config[1] !== ':') { diff --git a/package.json b/package.json index 4d7233b..77e9aea 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,15 @@ "license": "Apache-2.0", "main": "node/opencc.js", "scripts": { - "test": "mocha -R spec node/test.js" + "test": "mocha -R spec node/test.js", + "deploy": "node-pre-gyp package && (node-pre-gyp-github publish --release || exit 0)", + "install": "node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild" + }, + "binary": { + "module_name": "opencc", + "module_path": "./build/Release/", + "host": "https://github.com/BYVoid/OpenCC/releases/download/", + "remote_path": "{version}" }, "repository": { "type": "git", @@ -24,9 +32,11 @@ "Traditional Chinese" ], "devDependencies": { - "mocha": "2.2.5" + "mocha": "^3.5.0", + "node-pre-gyp-github": "^1.3.1" }, "dependencies": { - "nan": "^2.5.1" + "nan": "^2.7.0", + "node-pre-gyp": "^0.6.36" } } diff --git a/src/BinaryDict.cpp b/src/BinaryDict.cpp index 87a215d..bfeb3ac 100644 --- a/src/BinaryDict.cpp +++ b/src/BinaryDict.cpp @@ -24,7 +24,7 @@ using namespace opencc; size_t BinaryDict::KeyMaxLength() const { size_t maxLength = 0; for (const DictEntry* entry : *lexicon) { - maxLength = std::max(maxLength, entry->KeyLength()); + maxLength = (std::max)(maxLength, entry->KeyLength()); } return maxLength; } diff --git a/src/DartsDict.cpp b/src/DartsDict.cpp index 75f4c3d..07ebec8 100644 --- a/src/DartsDict.cpp +++ b/src/DartsDict.cpp @@ -135,7 +135,7 @@ DartsDictPtr DartsDict::NewFromDict(const Dict& thatDict) { for (size_t i = 0; i < lexiconCount; i++) { const DictEntry* entry = lexicon->At(i); keys[i] = entry->Key(); - maxLength = std::max(entry->KeyLength(), maxLength); + maxLength = (std::max)(entry->KeyLength(), maxLength); } doubleArray->build(lexicon->Length(), &keys[0]); dict->lexicon = lexicon; diff --git a/src/DictConverter.hpp b/src/DictConverter.hpp index f59c5ec..7d392a1 100644 --- a/src/DictConverter.hpp +++ b/src/DictConverter.hpp @@ -25,6 +25,6 @@ namespace opencc { * Converts a dictionary from a format to another. * @ingroup opencc_cpp_api */ -void ConvertDictionary(const string inputFileName, const string outputFileName, +OPENCC_EXPORT void ConvertDictionary(const string inputFileName, const string outputFileName, const string formatFrom, const string formatTo); } diff --git a/src/Exception.hpp b/src/Exception.hpp index 33cb5d9..98ebb60 100644 --- a/src/Exception.hpp +++ b/src/Exception.hpp @@ -24,9 +24,8 @@ #include "Export.hpp" -#ifdef _MSC_VER - -// Until Visual Studio 2013 (12.0), C++ 11 "noexcept" qualifier is not supported +#if defined(_MSC_VER) && _MSC_VER < 1900 +// Before Visual Studio 2015 (14.0), C++ 11 "noexcept" qualifier is not supported #define noexcept #endif // ifdef _MSC_VER diff --git a/src/PhraseExtractTest.cpp b/src/PhraseExtractTest.cpp index 3eced58..e1c8fef 100644 --- a/src/PhraseExtractTest.cpp +++ b/src/PhraseExtractTest.cpp @@ -16,6 +16,8 @@ * limitations under the License. */ +#include + #include "PhraseExtract.hpp" #include "TestUtils.hpp" diff --git a/src/TextDict.cpp b/src/TextDict.cpp index a6d29f3..73f5119 100644 --- a/src/TextDict.cpp +++ b/src/TextDict.cpp @@ -25,7 +25,7 @@ static size_t GetKeyMaxLength(const LexiconPtr& lexicon) { size_t maxLength = 0; for (const auto& entry : *lexicon) { size_t keyLength = entry->KeyLength(); - maxLength = std::max(keyLength, maxLength); + maxLength = (std::max)(keyLength, maxLength); } return maxLength; } -- 2.30.2